<script setup>
import { computed, watch } from "vue";
import TheHeader from "./coachfinder/components/layout/TheHeader.vue";
import store from "./coachfinder/store";
import router from "./router";

store.dispatch('tryLogin')

const didAutoLogout = computed(()=> {
  return store.getters.didAutoLogout
})

watch(didAutoLogout, function(curValue, oldValue) {
  if(curValue && curValue !== oldValue) {
    router.replace('/coaches')
  }
})

</script>

<template>
  <TheHeader></TheHeader>
  <router-view v-slot="slotProps">
    <transition name="route" mode="out-in">
      <component :is="slotProps.Component"></component>
    </transition>
  </router-view>
</template>

<style>
* {
  box-sizing: border-box;
}
html {
  font-family: "Roboto", sans-serif;
}
body {
  margin: 0;
}

.route-enter-from {
  opacity: 0;
  transform: translateY(-30px);
}
.route-leave-to {
  opacity: 0;
  transform: translateY(30px);
}

.route-enter-active {
  transition: all 0.3s ease-out;
}
.route-leave-active {
  transition: all 0.3s ease-in;
}

.route-enter-to,
.route-leave-from {
  opacity: 1;
  transform: translateY(0);
}
</style>
